﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：吕海乐 
    //
    // 文件名：InvoiceDetail.aspx.cs
    // 文件功能描述：发票审核，发票详细信息
    // 创建标识：吕海乐2009-04-30
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
// 审核时间：
// 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections.Generic;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.Model.Enum;

namespace HZ.DrugTrade.Web.Admin.ProcureManage
{
    public partial class InvoiceDetail : BasePage
    {
        public InvoiceDetail()
        {
            this.ModuleNo = Module.发票管理.ToString();
        }

        IBLL_Purchase ip = Factory.BLL_Purchase();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                SetBind();
            }
        }

        /// <summary>
        /// 绑定发票基本信息及明细
        /// </summary>
        private void SetBind()
        {
            //发票详细信息
            string InvoiceSerialID = Request.QueryString["InvoiceSerialID"];
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            int totalCount = 0;
            IList<Model.View.InvoiceDistribution> invoiceList = ip.GetInvoiceDistributionByWhere(new Model.Query.InvoiceDistribution() { InvoiceSerialID = InvoiceSerialID, SortFields = "PlanTime DESC" }, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            gvwInvoiceDetail.PageSize = AspNetPager1.PageSize;
            AspNetPager1.RecordCount = totalCount;
            gvwInvoiceDetail.DataSource = invoiceList;
            gvwInvoiceDetail.DataBind();

            //发票基本信息
            if (invoiceList.Count > 0)
            {
                txtInvoiceID.Text = invoiceList[0].InvoiceID;
                txtHospital.Text = invoiceList[0].HospitalName;
                txtAmount.Text = invoiceList[0].TotalAmount.ToString();
                string status = invoiceList[0].AuditStatus.ToString();
                if (status == "0")
                {
                    txtStatus.Text = "未审核";
                    txtTime.Text = "未审核";
                }
                else if (status == "1")
                {
                    txtStatus.Text = "审核通过";
                    lblAuditPerson.Visible = true;
                    txtAuditPerson.Visible = true;
                    txtAuditPerson.Text = invoiceList[0].AuditPerson.ToString();
                    txtTime.Text = invoiceList[0].AuditTime.ToString();
                }
                else if (status == "2")
                {
                    txtStatus.Text = "审核未通过";
                    lblAuditPerson.Visible = true;
                    txtAuditPerson.Visible = true;
                    txtAuditPerson.Text = invoiceList[0].AuditPerson.ToString();
                    lblReason.Visible = true;
                    txtReason.Visible = true;
                    txtReason.Text = invoiceList[0].NoPassReason.ToString();
                    txtTime.Text = invoiceList[0].AuditTime.ToString();
                }
            }
            else
            {
                PageError("该发票暂无明细信息！", "InvoiceCheck.aspx");
            }
        }
    }
}
